/**
 * Copyright (c) 2016-2020, Michael Yang 杨福海 (fuhai999@gmail.com).
 * <p>
 * Licensed under the GNU Lesser General Public License (LGPL) ,Version 3.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package cn.hg.jboot.commons.sms;

import com.jfinal.kit.JsonKit;

public class SmsMessage {

    public static SmsMessage create(String mobile, Object code, String template, String sign) {
        SmsMessage sms = new SmsMessage();
        sms.setCode(code.toString());
        sms.setSign(sign);
        sms.setMobile(mobile);
        sms.setTemplate(template);
        return sms;
    }

    // 手机号码
    private String mobile;

    // 阿里云和腾讯云需要签名
    private String sign;

    // 模板ID
    private String template;

    // 验证码
    private String code;

    public String getCode() {
        return this.code;
    }

    public String getMobile() {
        return this.mobile;
    }

    public String getSign() {
        return this.sign;
    }

    public String getTemplate() {
        return this.template;
    }

    /**
     * 发送短信
     */
    public boolean send() {
        return SmsSenderFactory.createSender().send(this);
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public void setTemplate(String template) {
        this.template = template;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return JsonKit.toJson(this);
    }


}
